package org.brisling.listenner.workflow;

import java.util.Map;

import org.activiti.engine.delegate.event.ActivitiEntityEvent;
import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.task.Task;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.brisling.common.SysConfig;
/**
 * 
 * <p>Title: ActivitiStartedListener</p>
 * <p>Description: 任务节点启动监听器</p>
 * <p>Company: tongking</p>
 * @author jackson wang
 * @since 1.0
 * @version 1.0
 * @date 2017年4月10日 下午5:43:13
 */
public class ActivitiStartedListener implements ActivitiEventListener{

	/** 
	  * 日志处理器 
	  */  
	private final static Log log=LogFactory.getLog(TaskCompleteListener.class);
	
	@Override
	public void onEvent(ActivitiEvent event) {
		// TODO Auto-generated method stub		
		ActivitiEntityEvent ae = (ActivitiEntityEvent)event;		
			
		Task task = (Task) ae.getEntity();
		
		Map<String,Map<String,String>> _ac = SysConfig.getFlowNodeMaps(
				 task.getTaskDefinitionKey(),task.getProcessDefinitionId());		
		
		Map<String,Object> map =task.getTaskLocalVariables();
		if(map.containsKey("userid")){
			log.debug("userid: " + map.get("userid"));
		}
		
		if(map.containsKey("deptid")){
			log.debug("deptid: " + map.get("deptid"));
		}
		
		log.info("ProcessDefinitionId : " +event.getProcessDefinitionId());
		log.info("ExecutionId : " +event.getExecutionId());
		log.info("ProcessInstanceId : " +event.getProcessInstanceId());
		
	}

	@Override
	public boolean isFailOnException() {
		// TODO Auto-generated method stub
		return false;
	}

}
